﻿<UserControl x:Class="GTServices.WPF.Client.Views.PatternListPickerView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:ext="clr-namespace:GTServices.WPF.Client.Extensions"
             xmlns:ent="clr-namespace:GTServices.Entities;assembly=GTServices.Entities"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" 
             xmlns:converters="clr-namespace:GTServices.WPF.Client.Converters"
             xmlns:cont="clr-namespace:GTServices.WPF.Client.Controls"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <DockPanel>
        <StackPanel HorizontalAlignment="Center" Orientation="Horizontal" DockPanel.Dock="Bottom">
            <cont:ClickableLabel Text="Ok"     cal:Message.Attach="[Event Click] = [Action Ok]" />
            <cont:ClickableLabel Text="Cancel" cal:Message.Attach="[Event Click] = [Action Cancel]" />
        </StackPanel>
        <DockPanel>
            <StackPanel DockPanel.Dock="Bottom">
                <Label Content="Filter: "/>
                <TextBox Text="{Binding FilterString, UpdateSourceTrigger=PropertyChanged}" />
            </StackPanel>
            <ListView ItemsSource="{Binding Patterns}"  
                              cal:Message.Attach="[Event SelectionChanged] = [Action SelectedItemChanged($executionContext)]"
                              ext:GridViewSort.AutoSort="True"
                              >
                <ListView.ItemContainerStyle>
                    <Style TargetType="{x:Type ListViewItem}">
                        <Setter Property="ToolTip" Value="{Binding CategoriesAsString}" />
                    </Style>
                </ListView.ItemContainerStyle>
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="Pattern" 
                                                DisplayMemberBinding="{Binding Pattern.PatternStr}"
                                                ext:GridViewSort.PropertyName="Pattern.PatternStr"
                                                />
                        <GridViewColumn Header="Language" 
                                                DisplayMemberBinding="{Binding Language.Name}"
                                                ext:GridViewSort.PropertyName="Language.Name"
                                                />
                        <GridViewColumn Header="First Category" 
                                                DisplayMemberBinding="{Binding FirstCategoryIfExists}"
                                                ext:GridViewSort.PropertyName="FirstCategoryIfExists"
                                                />
                    </GridView>
                </ListView.View>
                <ListView.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="Add" cal:Message.Attach="Add('Pattern')" />
                        <MenuItem Header="Remove" cal:Message.Attach="RemoveSelectedItems()" />
                        <MenuItem Header="Export" cal:Message.Attach="ExportSelectedItems()" />
                    </ContextMenu>
                </ListView.ContextMenu>
            </ListView>

        </DockPanel>

    </DockPanel>
</UserControl>
